/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.documents.main.action;

import com.documents.common.core.PageBean;
import com.documents.common.core.action.BaseActionSupport;
import com.documents.pojo.Institution;
import com.documents.service.knowledge.InstitutionService;
import java.util.List;
import org.apache.struts2.interceptor.ServletRequestAware;

/**
 *
 * @author Administrator
 */
public class InstitutionAction extends BaseActionSupport implements ServletRequestAware{
    
    
    private static final long serialVersionUID = 1005L;
    private InstitutionService institutionService;
    private List<Institution>  allInstitution; 
    private int page=1;
    private PageBean pageBean;
    private int pageSize = 20;
    private Institution institution; 
    private String actionURI;

    public String getActionURI() {
        return actionURI;
    }

    public void setActionURI(String actionURI) {
        this.actionURI = actionURI;
    }

    public List<Institution> getAllInstitution() {
        return allInstitution;
    }

    public void setAllInstitution(List<Institution> allInstitution) {
        this.allInstitution = allInstitution;
    }

    public Institution getInstitution() {
        return institution;
    }

    public void setInstitution(Institution institution) {
        this.institution = institution;
    }

    public InstitutionService getInstitutionService() {
        return institutionService;
    }

    public void setInstitutionService(InstitutionService institutionService) {
        this.institutionService = institutionService;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public PageBean getPageBean() {
        return pageBean;
    }

    public void setPageBean(PageBean pageBean) {
        this.pageBean = pageBean;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
    
    
    
    public String main() throws Exception {
        return "success";
    }

   
    public String institutionlist() throws Exception {

        pageBean = institutionService.getPageBean(page, pageSize, institution);

        return SUCCESS;
    }
    
     public void institutionDeleteById() {
        
        institutionService.delById(institution.getId());
        
    }

    public String addInstitutionInput() throws Exception {
        actionURI = "institutionsave";
        return SUCCESS;
    }

    public String institutionsave() throws Exception {
        institutionService.save(institution);
        return SUCCESS;
    }
    
       public String update() throws Exception {
        this.institutionService.update(institution);
        return SUCCESS;
    }
    
    public String updateInput() throws Exception {
        actionURI = "instUpdate";
        institution = this.institutionService.get(institution.getId());
        if(institution == null)
            return ERROR;
        else
            return SUCCESS;
    }
    
}
